package c.e.a.c.x;

import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import androidx.appcompat.widget.ListPopupWindow;
import com.google.android.material.textfield.MaterialAutoCompleteTextView;

/* compiled from: MaterialAutoCompleteTextView */
public class o implements OnItemClickListener {
    public final /* synthetic */ MaterialAutoCompleteTextView a;

    public o(MaterialAutoCompleteTextView materialAutoCompleteTextView) {
        this.a = materialAutoCompleteTextView;
    }

    public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
        Object selectedItem;
        View view2 = null;
        if (i < 0) {
            ListPopupWindow listPopupWindow = this.a.d;
            if (listPopupWindow.b()) {
                selectedItem = listPopupWindow.c.getSelectedItem();
            } else {
                selectedItem = null;
            }
        } else {
            selectedItem = this.a.getAdapter().getItem(i);
        }
        MaterialAutoCompleteTextView.a(this.a, selectedItem);
        OnItemClickListener onItemClickListener = this.a.getOnItemClickListener();
        if (onItemClickListener != null) {
            if (view == null || i < 0) {
                ListPopupWindow listPopupWindow2 = this.a.d;
                if (listPopupWindow2.b()) {
                    view2 = listPopupWindow2.c.getSelectedView();
                }
                view = view2;
                ListPopupWindow listPopupWindow3 = this.a.d;
                if (listPopupWindow3.b()) {
                    i = listPopupWindow3.c.getSelectedItemPosition();
                } else {
                    i = -1;
                }
                listPopupWindow3 = this.a.d;
                if (listPopupWindow3.b()) {
                    j = listPopupWindow3.c.getSelectedItemId();
                } else {
                    j = Long.MIN_VALUE;
                }
            }
            onItemClickListener.onItemClick(this.a.d.c, view, i, j);
        }
        this.a.d.dismiss();
    }
}
